﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Lk.WebTow.Migrations
{
    public partial class Initial : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "nc_dictbase",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Key_Type = table.Column<string>(maxLength: 20, nullable: false),
                    Key_Code = table.Column<string>(maxLength: 20, nullable: false),
                    Key_Value = table.Column<string>(maxLength: 50, nullable: false),
                    Code_Value = table.Column<string>(maxLength: 100, nullable: true),
                    Sort_ID = table.Column<int>(nullable: true),
                    OStatus = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_nc_dictbase", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "nc_dictcache",
                columns: table => new
                {
                    Cache_ID = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Parent_ID = table.Column<long>(nullable: false),
                    Class_List = table.Column<string>(maxLength: 50, nullable: true),
                    Class_Layer = table.Column<int>(nullable: true),
                    Sort_ID = table.Column<int>(nullable: true),
                    Title = table.Column<string>(maxLength: 50, nullable: false),
                    Depend = table.Column<string>(maxLength: 50, nullable: true),
                    Cache_Key = table.Column<string>(maxLength: 50, nullable: true),
                    Cache_Exp = table.Column<string>(maxLength: 50, nullable: true),
                    Cache_Desc = table.Column<string>(maxLength: 200, nullable: false),
                    Created_Name = table.Column<string>(maxLength: 20, nullable: true),
                    Created_Time = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "(getdate())"),
                    Updated_Name = table.Column<string>(maxLength: 20, nullable: true),
                    Updated_Time = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())"),
                    OStatus = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_nc_dictcache", x => x.Cache_ID);
                });

            migrationBuilder.CreateTable(
                name: "nc_manager_dept",
                columns: table => new
                {
                    Dept_ID = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    Parent_ID = table.Column<long>(nullable: true),
                    Class_List = table.Column<string>(maxLength: 500, nullable: true),
                    Class_Layer = table.Column<int>(nullable: true),
                    Sort_ID = table.Column<int>(nullable: true),
                    Dept_Name = table.Column<string>(maxLength: 50, nullable: false),
                    Dept_Desc = table.Column<string>(maxLength: 200, nullable: false),
                    Created_ID = table.Column<long>(nullable: true),
                    Created_Time = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "(getdate())"),
                    Updated_ID = table.Column<long>(nullable: true),
                    Updated_Time = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())"),
                    OStatus = table.Column<int>(nullable: false),
                    IsAudit = table.Column<int>(nullable: true, defaultValueSql: "((0))")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_nc_manager_dept", x => x.Dept_ID);
                });

            migrationBuilder.CreateTable(
                name: "nc_manager_log",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    user_id = table.Column<int>(nullable: true),
                    user_name = table.Column<string>(maxLength: 100, nullable: true),
                    action_type = table.Column<string>(maxLength: 100, nullable: true),
                    remark = table.Column<string>(maxLength: 255, nullable: true),
                    user_ip = table.Column<string>(maxLength: 30, nullable: true),
                    add_time = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_nc_manager_log", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "nc_manager_role",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    role_name = table.Column<string>(maxLength: 100, nullable: true),
                    role_type = table.Column<byte>(nullable: true),
                    is_sys = table.Column<byte>(nullable: true, defaultValueSql: "((0))")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_nc_manager_role", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "nc_navigation",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    parent_id = table.Column<int>(nullable: true, defaultValueSql: "((0))"),
                    channel_id = table.Column<int>(nullable: true, defaultValueSql: "((0))"),
                    nav_type = table.Column<string>(maxLength: 50, nullable: true, defaultValueSql: "('')"),
                    name = table.Column<string>(maxLength: 50, nullable: true, defaultValueSql: "('')"),
                    title = table.Column<string>(maxLength: 100, nullable: true, defaultValueSql: "('')"),
                    sub_title = table.Column<string>(maxLength: 100, nullable: true, defaultValueSql: "('')"),
                    icon_url = table.Column<string>(maxLength: 255, nullable: true, defaultValueSql: "('')"),
                    link_url = table.Column<string>(maxLength: 255, nullable: true, defaultValueSql: "('')"),
                    sort_id = table.Column<int>(nullable: true, defaultValueSql: "((99))"),
                    is_lock = table.Column<byte>(nullable: true, defaultValueSql: "((0))"),
                    remark = table.Column<string>(maxLength: 500, nullable: true, defaultValueSql: "('')"),
                    action_type = table.Column<string>(maxLength: 500, nullable: true, defaultValueSql: "('')"),
                    is_sys = table.Column<byte>(nullable: true, defaultValueSql: "((0))")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_nc_navigation", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "nc_manager",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    role_id = table.Column<int>(nullable: true),
                    role_type = table.Column<int>(nullable: true, defaultValueSql: "((2))"),
                    user_name = table.Column<string>(maxLength: 100, nullable: true),
                    password = table.Column<string>(maxLength: 100, nullable: true),
                    salt = table.Column<string>(maxLength: 20, nullable: true),
                    avatar = table.Column<string>(maxLength: 255, nullable: true),
                    real_name = table.Column<string>(maxLength: 50, nullable: true, defaultValueSql: "('')"),
                    telephone = table.Column<string>(maxLength: 30, nullable: true, defaultValueSql: "('')"),
                    email = table.Column<string>(maxLength: 30, nullable: true, defaultValueSql: "('')"),
                    is_audit = table.Column<byte>(nullable: true, defaultValueSql: "((0))"),
                    is_lock = table.Column<int>(nullable: true, defaultValueSql: "((0))"),
                    add_time = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())"),
                    dept_id = table.Column<long>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_nc_manager", x => x.id);
                    table.ForeignKey(
                        name: "FK_nc_MANAG_REFERENCE_nc_MANAG",
                        column: x => x.role_id,
                        principalTable: "nc_manager_role",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "nc_manager_role_value",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    role_id = table.Column<int>(nullable: true),
                    nav_name = table.Column<string>(maxLength: 100, nullable: true),
                    action_type = table.Column<string>(maxLength: 50, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_nc_manager_role_value", x => x.id);
                    table.ForeignKey(
                        name: "FK_nc_MANAG_REFERENCE_nc_MANAG_ROLE_VALUE",
                        column: x => x.role_id,
                        principalTable: "nc_manager_role",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_nc_manager_role_id",
                table: "nc_manager",
                column: "role_id");

            migrationBuilder.CreateIndex(
                name: "IX_nc_manager_role_value_role_id",
                table: "nc_manager_role_value",
                column: "role_id");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "nc_dictbase");

            migrationBuilder.DropTable(
                name: "nc_dictcache");

            migrationBuilder.DropTable(
                name: "nc_manager");

            migrationBuilder.DropTable(
                name: "nc_manager_dept");

            migrationBuilder.DropTable(
                name: "nc_manager_log");

            migrationBuilder.DropTable(
                name: "nc_manager_role_value");

            migrationBuilder.DropTable(
                name: "nc_navigation");

            migrationBuilder.DropTable(
                name: "nc_manager_role");
        }
    }
}
